<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>
        <li v-for="item,index in goods">
            <div v-if="(item.totalNum-item.buyNum)>0">
                <div>{{item.name}}---{{item.price}}</div>
                <div>剩余--------{{Number(item.totalNum)-Number(item.buyNum)}}</div>
                <div>购买<input v-model="item.buyNum"></div>
                <img width="200" height="200" :src="item.img" alt="">
            </div>
        </li>
    </ul>
</body>
<script src="https://unpkg.com/vue@3.2.47/dist/vue.global.js"></script>
<script>
    Vue.createApp({
         data: function(){
         return {
              goods:[
                 {name:'三星s22', price: 8,totalNum:100,buyNum:0, img:'https://img11.360buyimg.com/n1/s450x450_jfs/t1/90396/33/30995/88072/64210942Fc3fa924f/5c52c917298d6297.jpg'},
                 {name:'苹果12', price: 8,totalNum:100,buyNum:0, img:'https://img10.360buyimg.com/n1/s450x450_jfs/t1/132285/11/29715/72716/64246315F3d5d1ead/548be60628bb273a.jpg.avif'},
                 {name:'华为', price: 8,totalNum:100,buyNum:0, img:'https://img13.360buyimg.com/n7/jfs/t1/111107/14/22051/53193/6424e49cFc447a81f/bcea06eb4cc95345.jpg.avif'},



                 ]
         }
         }
    }).mount("body");





</script>
</html>